home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * STRTGEM2.S - A program to auto-start a GEM application
- *
- * Converted to AS68 format and modified by Charles F. Johnson
- *
- * Last revision: 03/16/87 14:41:28
- *******************************************************************************
-
- * Original comments:
- *******************************************************************************
- * STARTGEM.S 6-MAR-1987 by GHOST-Soft
- *
- * This program is used to start GEM programs from within the AUTO folder.
- *
- * The code is probably highly nonportable, as it heavily depends on the
- * internal organisation of code in TOS/GEM.
- * As this program works with ROM- as well as all disk-based versions
- * of German TOS, I'm pretty sure that this program works with foreign
- * versions of TOS, too.
- *******************************************************************************
-
-
- linef = $2C
- vbllist1 = $04D2
-
- gemdos = 1
- xbios = 14
-
-
- .text
-
- lea basepage(pc),a0 Get basepage address
- move.l $4(a7),(a0)
-
- clr.w -(sp) Try to open STARTGEM.INF
- pea startgem(pc)
- move.w #$3D,-(sp)
- trap #gemdos
- addq.l #8,sp
- tst.w d0 Error?
- bpl continue No, forge onward
-
- pea error(pc) Let the user know that he's short one
- move.w #9,-(sp) STARTGEM.INF file
- trap #gemdos
- addq.l #6,sp
- move.w #1,-(sp) Wait for a key
- trap #gemdos
- addq.l #2,sp
- bra wipeout And bail out
-
- continue:
- lea handle(pc),a5
- move.w d0,(a5) Save GEMDOS file handle
-
- pea filename(pc) Set buffer address
- move.l #64,-(sp) 64 bytes maximum
- move.w (a5),-(sp) File handle
- move.w #$3F,-(sp)
- trap #gemdos Read STARTGEM.INF
- add.l #12,sp
- tst.l d0 Error?
- bmi wipeout GERONIMO!
-
- lea filename(pc),a0
- add.l d0,a0 Number of bytes read is in d0
- clr.b -2(a0) Set zero at end of filename (before CR/LF)
-
- move.w (a5),-(sp) Close the file
- move.w #$3E,-(sp)
- trap #gemdos
- addq.l #4,sp
-
- clr.l -(a7)
- move.w #$20,-(a7) Enter super mode
- trap #gemdos
- addq.w #6,a7 Keep old super sp in d0
-
- moveq.l #$FF,d2
- move.l d2,linef set line-f emulator trap
- move.l #vbllist1,a5 Start searching at second vector
- move.w #6,d5
- ckvb1: tst.l (a5) Let's find an empty VBI slot in the queue
- beq ckvb2 Got one, skip ahead
- addq.l #4,a5 Keep searching
- dbf d5,ckvb1
- pea novbileft Print error message
- move.w #9,-(sp)
- trap #gemdos
- addq.l #6,sp
- bra wipeout And split
- ckvb2: lea vblank(pc),a2
- move.l a2,(a5) Set VBI vector
- lea vbiptr(pc),a2
- move.l a5,(a2) Save address of the vector we changed
-
- move.l d0,-(a7)
- move.w #$20,-(a7) exit super mode
- trap #gemdos
- addq.w #6,a7
-
- lea basepage(pc),a0 compute number of bytes to keep
- suba.l basepage(pc),a0
- clr.w -(a7) 0 = no error
- move.l a0,-(a7)
- move.w #$31,-(a7) terminate and stay resident
- trap #gemdos this call never returns
-
- wipeout:
- clr.w -(sp) If something goes wrong we end up here
- trap #gemdos (hopefully)
-
- vblank: moveq.l #$FF,d0
- cmp.l linef,d0
- beq H96
- lea vbiptr(pc),a0
- move.l (a0),a0
- clr.l (a0) Clear vblank vector
- movea.l linef,a0
- lea old_lf(pc),a1
- move.l a0,(a1) save old line-f vector (usually in low RAM)
- lea new_lf(pc),a1
- move.l a1,linef install new one
-
- * Find the address of the buffer that GEM uses for the
- * name of the program it is going to execute
-
- movea.l $16(a0),a0 get start of line-f table from instruction
- movea.l $7C8(a0),a0 get address of routine 'f7c8' from table
- movea.l $A(a0),a2 get address from instruction
- adda.w $10(a0),a2 add offset 0x1f56 from instruction
- lea pointer(pc),a1
- move.l a2,(a1) save buffer address
- H96:
- rts
-
- new_lf: movea.l $2(a7),a0 get addr. of instr. that caused exception
- cmpi.w #$F08C,(a0) 'f08c' is the line-f instr. we're looking for
- bne exit
- move.l old_lf(pc),linef restore old line-f vector
-
- movea.l pointer(pc),a0
- lea filename(pc),a1
- HB4: move.b (a1)+,(a0)+ copy filename into GEM buffer space
- bne HB4
-
- pea dta
- move.w #$1A,-(a7) set DTA
- trap #gemdos
- addq.l #6,a7
- move.w #$27,-(a7) don't look at volumes and directories
- pea filename(pc)
- move.w #$4E,-(a7) search first
- trap #gemdos
- addq.l #8,a7
- tst.w d0 status <> 0 indicates error
- bne exit
-
- lea filename(pc),a5 Pointer to filename
- clr.w d0
- move.b (a5)+,d0 Get drive specifier
- and.w #$DF,d0 Mask off lowercase
- sub.b #65,d0 Convert from ASCII
- move.w d0,-(sp)
- move.w #$0E,-(sp)
- trap #gemdos Set current drive
- addq.l #4,sp
-
- addq.l #1,a5
- lea pathname(pc),a4
- move.w #63,d5
- pathlp: tst.b (a5) Build a pathname from the filename
- beq plx1 supplied by the user
- move.b (a5)+,(a4)+
- dbf d5,pathlp
- plx1: move.w #63,d5
- plp2: cmp.b #'\',-(a4)
- beq plx2
- dbf d5,plp2
- plx2: addq.l #1,a4
- clr.b (a4)
- pea pathname Set path
- move.w #$3B,-(sp)
- trap #gemdos
- addq.l #6,sp
-
- movea.l $2(a7),a0 get addr. of instr. that caused exception
- HDE: cmpi.w #$F4B8,(a0) look for line-f instruction 'f4b8'
- beq doload
- addq.l #2,a0
- cmpa.l #$FEFFFE,a0 test for ROM end
- beq exit
- cmpa.l #$78000,a0 test for RAM end (on 512K machine)
- bne HDE {RAM-TOS usually loads much lower}
-
- exit: movea.l old_lf(pc),a0 resume execution of regular line-f handler
- jmp (a0)
-
- doload:
- move.w (a7)+,d2 pop status word
- addq.w #4,a7 destroy addr. of instr. 'f08c'
- move d2,sr restore status register
- adda.w #$38,a7 destroy parameters of instr. 'f08c'
- jmp (a0) jump to instruction 'f4b8'
-
- .even
-
- dta: ds.b 44
-
- old_lf: ds.l 1
-
- pointer:
- ds.l 1
-
- vbiptr:
- ds.l 1
-
- handle:
- ds.w 1
-
- filename:
- ds.b 72
-
- pathname:
- ds.b 64
-
- startgem:
- dc.b 'STARTGEM.INF',0
-
- error:
- dc.b "Error! - Can't find STARTGEM.INF...",13,10,13,10
- dc.b ' To use STARTGEM.PRG, first create',13,10
- dc.b 'a text file called STARTGEM.INF in',13,10
- dc.b 'the main directory of your boot disk,',13,10
- dc.b 'consisting of the filename of the',13,10
- dc.b 'program you wish to auto-run.',13,10,13,10
- dc.b ' The first three characters of this',13,10
- dc.b 'filename MUST consist of the drive',13,10
- dc.b 'name (A, B, etc.), a colon, and a',13,10
- dc.b 'backslash. Examples:',13,10,13,10
- dc.b 'A:\1STWORD.PRG',13,10
- dc.b 'C:\UTILITY\ARC\ARC.TTP',13,10,13,10
- dc.b 'Press any key to exit.',13,10,0
-
- novbileft:
- dc.b 'Oops! No vertical blank interrupt',13,10
- dc.b 'vectors left!',13,10,0
-
- .even
- basepage:
- dc.b 'EOPA'
-